export default {
    data(){
        return{
            msg:''
        }
    },
    methods:{
        login(){
            if(this.$refs.username.value!='' && this.$refs.password.value!=''){
                // console.log(this.$refs.username.value)
                // console.log(this.$refs.password.value)
                var that=this
                this.$store.state.user.map(x=>{
                    if(x.username==that.$refs.username.value && x.password==that.$refs.password.value){
                        this.msg="登录成功"
                        this.$store.state.username='hi,'+x.username
                        this.$store.state.shopingList=[]
                        this.$store.state.car_num_all=0
                        this.$router.push({ path: '/' })
                    }else{
                        this.msg="用户名或密码错误"
                    }
                })
            }else{
                this.msg="用户名和密码不能为空"
            }
        }
    }
}